package com.ruoyi.web.controller.system;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ProjectLogDetail;
import com.ruoyi.system.service.IProjectLogDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 竞标记录详细Controller
 *
 * @author ruoyi
 * @date 2024-09-04
 */
@RestController
@RequestMapping("/system/projectLogDetail")
public class ProjectLogDetailController extends BaseController {
    @Resource
    private IProjectLogDetailService projectLogDetailService;

    /**
     * 查询竞标记录详细列表
     */
    //@PreAuthorize("@ss.hasPermi('system:projectLogDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectLogDetail projectLogDetail) {
        startPage();
        List<ProjectLogDetail> list = projectLogDetailService.selectProjectLogDetailList(projectLogDetail);
        return getDataTable(list);
    }

    /**
     * 导出竞标记录详细列表
     */
    //@PreAuthorize("@ss.hasPermi('system:projectLogDetail:export')")
    @Log(title = "竞标记录详细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectLogDetail projectLogDetail) {
        List<ProjectLogDetail> list = projectLogDetailService.selectProjectLogDetailList(projectLogDetail);
        ExcelUtil<ProjectLogDetail> util = new ExcelUtil<ProjectLogDetail>(ProjectLogDetail.class);
        util.exportExcel(response, list, "竞标记录详细数据");
    }

    /**
     * 获取竞标记录详细详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:projectLogDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(projectLogDetailService.selectProjectLogDetailById(id));
    }

    /**
     * 新增竞标记录详细
     */
    //@PreAuthorize("@ss.hasPermi('system:projectLogDetail:add')")
    @Log(title = "竞标记录详细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectLogDetail projectLogDetail) {
        return toAjax(projectLogDetailService.insertProjectLogDetail(projectLogDetail));
    }

    /**
     * 修改竞标记录详细
     */
    //@PreAuthorize("@ss.hasPermi('system:projectLogDetail:edit')")
    @Log(title = "竞标记录详细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody List<ProjectLogDetail> details) {
        return toAjax(projectLogDetailService.updateProjectLogDetail(details));
    }

    /**
     * 删除竞标记录详细
     */
    //@PreAuthorize("@ss.hasPermi('system:projectLogDetail:remove')")
    @Log(title = "竞标记录详细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(projectLogDetailService.deleteProjectLogDetailByIds(ids));
    }
}
